#include <iostream>
using namespace std;
class B;
class A
{
    private:
        int a;
    public:
        void setData(int x)
        {
            a = x;
        }
        friend void fun(A, B);
};

class B
{
    private:
        int b;
    public:
        void setData(int y)
        {
            b = y;
        }
        friend void fun(A, B);
};

void fun(A o1, B o2)   // friend to 2 (multiple) classes
{
    cout << "sum is: " << o1.a + o2.b;
}

int main()
{
    A o1;
    B o2;
    o1.setData(5);
    o2.setData(10);
    fun(o1, o2);
}